package com.artisan.domain.service;

import com.artisan.domain.dto.AdTypeDto;
import com.artisan.domain.entity.MAdType;
import com.artisan.domain.info.AdInfo;
import com.artisan.domain.repositoryInterface.IAdRepository;
import com.artisan.domain.repositoryInterface.IAdTypeRepository;
import com.artisan.domain.serviceInterface.IAdTypeService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 广告类型业务类
 */
@Service
public class AdTypeService implements IAdTypeService {
    private final IAdTypeRepository adTypeRepository;

    public AdTypeService(IAdTypeRepository adTypeRepository) {
        this.adTypeRepository = adTypeRepository;
    }
    @Override
    public List<AdTypeDto> findList(int status) {
        List<MAdType> models = this.adTypeRepository.findList(status);
        List<AdTypeDto> dtos = new ArrayList<>();
        models.forEach(model -> {
            AdTypeDto dto = new AdTypeDto();
            dto.setId(model.getId());
            dto.setName(model.getName());
            dto.setAddDate(model.getAddDate());
            dto.setStatus(model.getStatus());
            dtos.add(dto);

        });
        return dtos;
    }
}
